import React from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
//取别名为Router

//router
import IndexPg from './pages/IndexPg';
import LoginPg from './pages/LoginPg';

//导入所有子路由
import CollectionPage from 'pages/subPg/CourseCollectionCon';
import CoursePage from 'pages/subPg/CourseCon';
import CrawlerPage from 'pages/subPg/CrawlerCon';
import RecomCoursePage from 'pages/subPg/RecomCourseCon';
import SliderPage from 'pages/subPg/SliderCon';
import StudentPage from 'pages/subPg/StudentCon';
import TeacherPage from 'pages/subPg/TeacherCon';
import ErrorPage from 'pages/subPg/ErrorCon';

function App() {
  return (
    <Router>
        <Switch>
          <Route component={LoginPg} path="/login" />
          <Route path="/" render ={ props => (
            <IndexPg history ={ props.history }>
              <Switch>
                  <Route component={ CollectionPage} path="/collection" />
                  <Route component={ CoursePage} path="/course" />
                  <Route component={ CrawlerPage } path="/crawler" />
                  <Route component={ RecomCoursePage } path="/recom_course" />
                  <Route component={ SliderPage} path="/slider" />
                  <Route component={ StudentPage} path="/student" />
                  <Route component={ TeacherPage} path="/teacher" />
                  <Route component={ ErrorPage} />
                  {/* 任意不符合规则的都会走最下面 不传参数 */}
              </Switch>
            </IndexPg>
          )} />
        </Switch>
    </Router>
  );
}

export default App;
